#include "Coordinate.h"

//Coordinate Coordinate::operator+(const Coordinate& other) const
//{
//    Coordinate coordinate;
//    coordinate._x = _x + other._x;
//    coordinate._y = _y + other._y;
//    return coordinate;
//}
//
//Coordinate Coordinate::operator-(const Coordinate& other) const
//{
//    Coordinate coordinate;
//    coordinate._x = _x - other._x;
//    coordinate._y = _y - other._y;
//    return coordinate;
//}
//
//Coordinate Coordinate::operator*(const Coordinate& other) const
//{
//    Coordinate coordinate;
//    double radian = 3.1415926 * _a / 180;
//    coordinate._x = other._x * cos(radian) - other._y * sin(radian);
//    coordinate._y = other._x * sin(radian) + other._y * cos(radian);
//
//    return coordinate;
//}

Coordinate& Coordinate::operator+=(const Coordinate& other)
{
    _x += other._x;
    _y += other._y;
    return *this;
}

Coordinate rotate(Coordinate& pos, Coordinate& center)
{
    Coordinate temp, ret;
    temp._x = pos._x - center._x;
    temp._y = pos._y - center._y;

    double radian = 3.1415926 * center._a / 180;
    ret._x = temp._x * cos(radian) - temp._y * sin(radian);
    ret._y = temp._x * sin(radian) + temp._y * cos(radian);

    ret._x = ret._x + center._x;
    ret._y = ret._y + center._y;
    return ret;
}